package cn.cloud9.config;

import cn.cloud9.intf.UserService;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author OnCloud9
 * @description
 * @project Springboot-CXF
 * @date 2022年04月23日 17:30
 */
@Configuration
public class JaxRsConfig {
    @Autowired
    Bus bus;

    @Autowired
    private UserService userService;

    @Bean
    public Server createServer() {
        final JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
        factoryBean.setAddress("/userService");
        factoryBean.setBus(bus);
        factoryBean.setServiceBean(userService);
        return factoryBean.create();
    }
}
